<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateRolesTable extends Migrator
{
    public function change()
    {
        $table = $this->table('roles', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_unicode_ci']);
        $table->addColumn('name', 'string', ['limit' => 50, 'null' => false, 'comment' => '角色名称'])
              ->addColumn('description', 'string', ['limit' => 255, 'null' => true, 'comment' => '角色描述'])
              ->addColumn('created_at', 'timestamp', ['null' => true])
              ->addColumn('updated_at', 'timestamp', ['null' => true])
              ->addIndex(['name'], ['unique' => true])
              ->create();
    }
} 